// pages/my-account//my-account.js
import { URL, SER_KEY } from "../../config.js"
import { POST, GET } from "../../utils/request.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabNum:1,
    consList:[],//消费列表
    rechargeList:[]//充值列表
  },

  tabChange:function(event){
    if (event.currentTarget.dataset.index==1){
      this.setData({ tabNum: 1 })
      this.getList()
    }
    if (event.currentTarget.dataset.index==2){
      this.setData({ tabNum: 2 })
     this.getConsList()
    }
    
  },
  getConsList(){
    let that=this
    let url = URL.HTTP_BASE_INTRANET + SER_KEY.SER_KEY19;
    let data = {
      appid: getApp().globalData.appId,
      sessionId: wx.getStorageSync('session_id'),
      shopId: that.data.shopMsg.id,
      status: 'TRADE_FINISHED'
    };
    GET(url, data, (ret) => {
      // console.log(ret.data.lorder)
      if (ret.statusCode == 200) {
        wx.stopPullDownRefresh()
        that.setData({
          consList: ret.data.lorde
        })

      } else {
        wx.showToast({
          title: '数据走丢啦，请稍后再试',
          icon: 'none'
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getList()
    let shopMsg = JSON.parse(wx.getStorageSync('shopData'))
    console.log(shopMsg)
    this.setData({
      shopMsg: shopMsg
    })
  },
  getList() {
    let that = this;
    let url = URL.HTTP_BASE_INTRANET + SER_KEY.SER_KEY23;
    let data = {
      appid: getApp().globalData.appId,
      sessionId: wx.getStorageSync('session_id')
    };
    GET(url, data, (ret) => {
      if (ret.statusCode == 200) {
        console.log(ret)
        wx.stopPullDownRefresh()
        // let data = ret.data.lproduct
        that.setData({
          
        })
      } else {
        wx.showToast({
          title: '数据走丢啦，请稍后再试',
          icon: 'none'
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getList()
    this.getConsList()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})